package com.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.PestBean;
import com.project.dao.IPestDao;
import com.project.service.IPestService;
import jdk.jfr.Percentage;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author RJ
 * @date 2022/9/14 15:47
 */
@Service
@Transactional
public class PestServiceImpl extends ServiceImpl<IPestDao, PestBean> implements IPestService {

    @Override
    public void addPest(PestBean pest) {
        this.save(pest);
    }

    @Override
    public PestBean getPestInfo(Integer pestId) {
        return this.getById(pestId);
    }

    @Override
    public IPage<PestBean> cutPestByItem(Integer pageNo, Integer pageSize, String pestName, String pestHost) {
        Page<PestBean> page = new Page<>(pageNo, pageSize);
        IPage<PestBean> iPage = this.baseMapper.cutPestByItem(page, pestName, pestHost);
        return iPage;
    }
}
